home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr18 / mrun210.zip / MRUN210D.WAS < prev    next >
Text File  |  1993-04-28  |  23KB  |  795 lines

  1. ;MailRun v2.10:  Part D, adddlfile
  2. ;1992-1993 Gerald P. Sully, all rights reserved.
  3.  
  4. #comment
  5. **************************************************************************
  6. **************************************************************************
  7. * This file contains routines related to adding a "Download File"
  8. * item to a mailrun.  It puts up the Download Files dialog box,
  9. * which displays the contents of the available files index (the
  10. * *.idx file for the BBS).  When a file is selected from the 
  11. * list, a detailed description is displayed from the *.dbf file 
  12. * for the BBS).
  13. * The index may be obtained either through the getnewfiles() 
  14. * procedure, which opens *.QWK files and checks for a newfiles.dat 
  15. * file, or by importing a list from an external source.  In either
  16. * case, the file is parsed by the import() procedure.
  17. **************************************************************************
  18. **************************************************************************
  19. #endcomment
  20.  
  21. #define MRUN210D
  22. #define MRUN210DE
  23.  
  24. #include "mrun210.h"
  25.  
  26. string DXFileTabs, BBSidx, BBSdbf, DLPurgeLimit
  27. integer DLSortField
  28.  
  29. #comment
  30. *********************************************************************
  31. * MAIN()
  32. * Calls checkchild(), checkperm(), makebbslist(), makedesc(),
  33. * getbbsi(), getitemi(), getbbscoord(), getitemcoord(), 
  34. * getnewfiles(), gettaskstring(), import(), importwarning(), 
  35. * openfile(), dlfilebox(), deldlfile(), insertitem(),
  36. * menudim(), makefullname(), interfaceon(), interfaceoff(),
  37. * sortidx(), purgeoldfiles(), clearfiledesc()
  38. * Adds a GetFile item to the mailrun.
  39. *********************************************************************
  40. #endcomment
  41.  
  42. proc main
  43. string dlfileString, statstring, ImportFile, ImportFilter
  44. string Perm
  45. integer dialogstatus
  46. integer i, j
  47.     menudim()
  48.     checkchild()
  49.     findfirst MailRun
  50.     MailRunTrunc = $FILENAME
  51.     
  52.     ;Set up variables for the dlfilebox
  53.     DXFileTabs = "58,92,130,305,315,319,322,325,328"
  54.     i = getbbsi()
  55.     j = getitemi()
  56.     profilerd MailRun "MailRun" "DLSortField" DLSortField
  57.     profilerd MailRun "MailRun" "DLPurgeLimit" DLPurgeLimit
  58.     makebbslist()
  59.     FileDesc = makefullname(TempDir, "DESC.TMP")
  60.     BBSdbf = makefullname(MailRunDir, BBS)
  61.     strcat BBSdbf ".DBF"
  62.     BBSidx = makefullname(MailRunDir, BBS)
  63.     strcat BBSidx ".IDX"
  64.     
  65.     ;Update the available files database
  66.     clearfiledesc()
  67.     FileName = ""
  68.     dlfilebox()
  69.     purgeoldfiles()
  70.     getnewfiles()
  71.     updatedlg 16
  72.     dialogstatus = $DIALOG
  73.     while dialogstatus != 1
  74.         switch dialogstatus
  75.             case 10
  76.                 ;User selected "Add"
  77.                 if not NULLSTR FileName
  78.                     ;only add request if a filename has been entered
  79.                     strupr FileName
  80.                     Perm = checkperm()
  81.                     strfmt dlfileString "1,%s,GetFile,%s,%s" Perm FileName Conf
  82.                     strfmt statstring \
  83.                         "Added to %s:  `"Download %s from Conference %s`"" \
  84.                         BBS FileName Conf
  85.                     ;Update MAILRUN.INI, task list
  86.                     j++
  87.                     insertitem(j, dlfileString)
  88.                     gettaskstring(i, j)
  89.                     statmsg statstring
  90.                 endif
  91.             endcase
  92.             case 11
  93.                 ;User selected "Delete"
  94.                 deldlfile()
  95.                 updatedlg 148
  96.             endcase
  97.             case 12
  98.                 ;User selected "Import"
  99.                 ;allow the user to abort operation if it will take too long
  100.                 if importwarning()
  101.                     ImportFilter = makefullname(MailRunDir, "*.lst")
  102.                     sdlgfopen "Import File List" ImportFilter ImportFile
  103.                     if SUCCESS
  104.                         ;if the user has selected a file to import...
  105.                         interfaceoff()
  106.                         statmsg "Updating database...      0 files added..."
  107.                         import(ImportFile, 0)
  108.                         sortidx(BBSidx, DLSortField)
  109.                         statmsg ""
  110.                         interfaceon()
  111.                         updatedlg 16
  112.                     endif
  113.                 endif
  114.             endcase
  115.             case 13
  116.                 ;User selected "Purge"
  117.  
  118.                 ;Set index and database files to zero length.  Set display file
  119.                 ;to a space character.  The latter is necessary becuase of an 
  120.                 ;ASPECT bug that won't allow update of an ftext box if the 
  121.                 ;displayed file is nonexistent or zero length.
  122.  
  123.                 openfile(BBSidxFile, BBSidx, _CREATE, _NORMAL)
  124.                 openfile(BBSdbfFile, BBSdbf, _CREATE, _NORMAL)
  125.                 fclose BBSidxFile
  126.                 fclose BBSdbfFile
  127.                 clearfiledesc()
  128.                 FileName = ""
  129.                 updatedlg 148
  130.             endcase
  131.             case 50
  132.                 ;User selected a new sort method
  133.                 profilewr MailRun "MailRun" "DLSortField" DLSortField
  134.                 sortidx(BBSidx, DLSortField)
  135.                 updatedlg 16
  136.             endcase
  137.             case 130
  138.                 ;User selected a file from the index window
  139.                 strextract FileName FileChoice "`t" 0
  140.                 makedesc(BBSdbf)
  141.                 updatedlg 132
  142.             endcase
  143.             case 170
  144.                 ;User changed BBS with the combobox
  145.                 i = getbbscoord()
  146.                 j = getitemcoord()
  147.                 TaskItem = gettaskstring(i, 0)
  148.                 ;Update the available files database
  149.                 BBSdbf = makefullname(MailRunDir, BBS)
  150.                 strcat BBSdbf ".DBF"
  151.                 BBSidx = makefullname(MailRunDir, BBS)
  152.                 strcat BBSidx ".IDX"
  153.                 purgeoldfiles()
  154.                 getnewfiles()
  155.                 clearfiledesc()
  156.                 FileName = ""
  157.                 updatedlg -1
  158.             endcase
  159.             case 230
  160.                 clearfiledesc()
  161.                 updatedlg 4
  162.             endcase
  163.         endswitch
  164.         dialogstatus = $DIALOG
  165.     endwhile
  166.     profilewr MailRun "MailRun" "DLPurgeLimit" DLPurgeLimit
  167.     statmsg ""
  168. endproc
  169.  
  170.  
  171. #comment
  172. *********************************************************************
  173. * IMPORTWARNING()
  174. * Called by main()
  175. * If sorting or duplicate filter is set, warns that an
  176. * import operation may take a long time.
  177. *********************************************************************
  178. #endcomment
  179.  
  180. func importwarning : integer
  181. string WarningMsg
  182. integer Response
  183.     if (DLSortField != 1) && NewfileFilter
  184.         WarningMsg = "You have chosen to import a list of files with \
  185. the duplicate file filter and sorting enabled.  With large file \
  186. lists, this may result in very slow performance.`r`n`r`nDo you \
  187. wish to continue?"
  188.     elseif DLSortField != 1
  189.         WarningMsg = "You have chosen to import a list of files with \
  190. sorting enabled.  With large file \
  191. lists, this may result in very slow performance.`r`n`r`nDo you \
  192. wish to continue?"
  193.     elseif NewfileFilter
  194.         WarningMsg = "You have chosen to import a list of files with \
  195. the duplicate file filter enabled.  With large file \
  196. lists, this may result in very slow performance.`r`n`r`nDo you \
  197. wish to continue?"
  198.     else
  199.         return 1
  200.     endif
  201.     sdlgmsgbox "MailRun Message" WarningMsg QUESTION YESNO Response 2
  202.     switch Response
  203.         case 6
  204.             return 1
  205.         endcase
  206.         case 7
  207.             return 0
  208.         endcase
  209.     endswitch
  210. endfunc
  211.  
  212.  
  213. #comment
  214. *********************************************************************
  215. * PURGEOLDFILES()
  216. * Called by main()
  217. * Calls openfile(), interfaceon(), interfaceoff(),
  218. * checkfile(), makefullname()
  219. * Purges aged files from the download database and compresses
  220. * the database.  The current date is checked against each file
  221. * date, and those that are aged are discarded.  The number of
  222. * days a file can be kept is determined by DLPurgeLimit, which
  223. * is set in the Download Files dialog box.
  224. *********************************************************************
  225. #endcomment
  226.  
  227. proc purgeoldfiles
  228. string Oldidx, Olddbf, idxString, PurgeMsg
  229. string DLFileTrunc, FileSize, FileDate, FDesc, DescBegin, DescLength
  230. integer char, count
  231. long DLPurgeDays, counter, OldDate, FD, TD, DB, DL, NDB
  232.     Oldidx = makefullname(TempDir, "oldidx.tmp")
  233.     Olddbf = makefullname(TempDir, "olddbf.tmp")
  234.     if !(checkfile(BBSidx) && checkfile(BBSdbf))
  235.         return
  236.     endif
  237.     findfirst BBSidx
  238.     strsltime $FDATE "00:00:00" FD
  239.     strsltime $DATE "00:00:00" TD
  240.     atol DLPurgeLimit DLPurgeDays
  241.     if DLPurgeDays && (FD < TD)
  242.         statmsg "Purging old files...    Files in database:  0"
  243.         interfaceoff()
  244.         
  245.         ;save the original dates of the database files so that
  246.         ;getnewfiles() can function properly
  247.         getfltime BBSidx OldDate
  248.         
  249.         copyfile BBSidx Oldidx
  250.         copyfile BBSdbf Olddbf
  251.         openfile(OldidxFile, Oldidx, _READWRITE, _TEXT)
  252.         openfile(OlddbfFile, Olddbf, _READWRITE, _NORMAL)
  253.         openfile(BBSidxFile, BBSidx, _CREATE, _TEXT)
  254.         openfile(BBSdbfFile, BBSdbf _CREATE, _NORMAL)
  255.         count = 0
  256.         fgets OldidxFile idxString
  257.         while not feof OldidxFile
  258.             ;loop through the old .idx file
  259.             strextract FileDate idxString "`t" 2
  260.             strsltime FileDate "00:00:00" FD
  261.             if FD < (TD - (DLPurgeDays * 86400))
  262.                 ;if the file is older than allowed, discard it
  263.                 fgets OldidxFile idxString
  264.                 loopwhile
  265.             endif
  266.             count ++
  267.             strfmt PurgeMsg \
  268.                 "Purging old files...    Files in database:  %d" count
  269.             statmsg  PurgeMsg
  270.             strextract DLFileTrunc idxString "`t" 0
  271.             strextract FileSize idxString "`t" 1
  272.             strextract FDesc idxString "`t" 3
  273.             strextract DescBegin idxString "`t" 4
  274.             strextract DescLength idxString "`t" 5
  275.             atol DescBegin DB
  276.             atol DescLength DL
  277.             ftell BBSdbfFile NDB
  278.             ;go to the beginning of the file description
  279.             fseek OlddbfFile DB 0
  280.             ;copy the description to the new .dbf file
  281.             for counter = 1 upto DL
  282.                 fgetc OlddbfFile char
  283.                 fputc BBSdbfFile char
  284.             endfor
  285.             ;add the index line to the new .idx file
  286.             fstrfmt BBSidxFile "%s`t%s`t%s`t%s`t%ld`t%ld`r`n" \
  287.                 DLFileTrunc FileSize FileDate FDesc NDB DL
  288.             fgets OldidxFile idxString
  289.         endwhile
  290.         fclose BBSidxFile
  291.         fclose BBSdbfFile
  292.         fclose OldidxFile
  293.         fclose OlddbfFile
  294.         delfile Oldidx
  295.         delfile Olddbf
  296.         ;restore the original dates of the database files
  297.         setfltime BBSidx OldDate
  298.         setfltime BBSdbf OldDate
  299.         interfaceon()
  300.         statmsg ""
  301.     endif    
  302. endproc
  303.  
  304.  
  305. #comment
  306. *********************************************************************
  307. * GETNEWFILES()
  308. * Called by main()
  309. * Calls openfile(), interfaceon(), interfaceoff(), checkfile()
  310. * makefullname(), import(), sortidx(), findstring()
  311. * Extracts NEWFILES.DAT from a BBS .QWK packet.  This is
  312. * used to update an index file, BBS.IDX, and a database of
  313. * descriptions, BBS.DBF, where "BBS" is the BBS ID.  The
  314. * first line of each file description in NEWFILES.DAT is
  315. * converted to a tab delimited string containing the file's
  316. * name, size, date and partial description.  The starting
  317. * point of the full description in the database and the
  318. * length of the description are appended and the entire
  319. * string is appended to the index file.  Tabstops in the
  320. * index flistbox in dlfilebox() allow push the index and
  321. * length beyond the right edge of the box.  The full
  322. * description of each file is appended to the database file.
  323. *********************************************************************
  324. #endcomment
  325.  
  326. proc getnewfiles
  327. string QWKFile, NewFiles, MailDir, QWKArchiver
  328. string FPCmdLine, MRUnarcBat, Drive
  329. integer ArcId, WinId, FirstPass, NumFiles
  330. integer i, n
  331. long QWKTime, IDXTime
  332.     profilerd MailRun "MailRun" "MailDir" MailDir
  333.     profilerd MailRun BBS "QWKArchiver" QWKArchiver
  334.     QWKFile = makefullname(MailDir, BBS)
  335.     strcat QWKFile ".QWK"
  336.  
  337.     ;Only update the database if there is a more recent
  338.     ;QWK file for the BBS
  339.  
  340.     if isfile QWKFile
  341.         getfltime QWKFile QWKTime
  342.     else
  343.         QWKTime = 0
  344.     endif
  345.  
  346.     if checkfile(BBSidx) && checkfile(BBSdbf)
  347.         ;if both database files exist, get their time stamps
  348.         getfltime BBSidx IDXTime
  349.     else
  350.         IDXTime = 0
  351.     endif
  352.     
  353.     profilerd MailRun "MailRun" "SavePackets" n
  354.     profilerd MailRun "MailRun" "NewfileFilter" NewfileFilter
  355.     FirstPass = 1
  356.     NumFiles = 0
  357.     i = 0
  358.     interfaceoff()
  359.     while (QWKTime > IDXTime) && (i <= n)
  360.         if FirstPass
  361.             statmsg "Updating database...      0 files added..."
  362.             FirstPass = 0
  363.         endif
  364.  
  365.         ;Set up the unarchive command string and run it.
  366.  
  367.         NewFiles = makefullname(TempDir, "NEWFILES.DAT")
  368.         if isfile NewFiles
  369.             delfile NewFiles
  370.         endif
  371.         if strcmpi QWKArchiver "FPZIPX.EXE"
  372.             ;if the QWK archiver is FlashPoint ZIP (Windows-based)...
  373.             strfmt FPCmdLine "fpzipx.exe -e %s %s NEWFILES.DAT" QWKFile TempDir
  374.             run FPCmdLine MINIMIZED ArcId
  375.             taskwin ArcId WinId
  376.             ;stall until execution is finished
  377.             while !(findstring($TITLEBAR, "FlashPoint")) || (WinId == $ACTIVEWIN)
  378.             endwhile
  379.             exittask ArcId
  380.         else
  381.             ;otherwise, create a batch file and run it
  382.             MRUnarcBat = makefullname(TempDir, "MRUnarc.BAT")
  383.             openfile(MRUnarcFile, MRUnarcBat, _CREATE, _NORMAL)
  384.             substr Drive TempDir 0 2
  385.             fstrfmt MRunarcFile "%s`r`ncd %s`r`n" Drive TempDir
  386.             switch QWKArchiver
  387.                 case "ARJ.EXE"
  388.                 case "LHA.EXE"
  389.                 case "LHARC.EXE"
  390.                     fstrfmt MRUnarcFile "%s e %s NEWFILES.DAT`r`n" \
  391.                         QWKArchiver QWKFile
  392.                 endcase
  393.                 case "PKUNZIP.EXE"
  394.                 case "PKXARC.EXE"
  395.                     fstrfmt MRUnarcFile "%s %s NEWFILES.DAT`r`n" \
  396.                         QWKArchiver QWKFile
  397.                 endcase
  398.                 case "ZOO.EXE"
  399.                     fstrfmt MRUnarcFile "%s -extract NEWFILES.DAT" \
  400.                         QWKArchiver QWKFile
  401.                 endcase
  402.             endswitch
  403.             fclose MRUnarcFile
  404.             run MRUnarcBat MINIMIZED ArcId
  405.             ;Stall the script until unzipping is complete
  406.             while istask ArcId
  407.             endwhile
  408.         endif
  409.         import(NewFiles, &NumFiles)
  410.         QWKFile = makefullname(MailDir, BBS)
  411.         strfmt QWKFile "%s.QW%d" QWKFile i
  412.         if isfile QWKFile
  413.             getfltime QWKFile QWKTime
  414.         else
  415.             QWKTime = 0
  416.         endif
  417.         i++
  418.     endwhile
  419.     if NumFiles
  420.         sortidx(BBSidx, DLSortField)
  421.     endif
  422.     setfltime BBSidx $LTIME
  423.     setfltime BBSdbf $LTIME
  424.     interfaceon()
  425.     statmsg ""
  426. endproc
  427.  
  428.  
  429. #comment
  430. *********************************************************************
  431. * IMPORT()
  432. * Called by main(), getnewfiles()
  433. * Calls openfile(), checkfile(), checknfstring(), findstring()
  434. * Imports a file list into the download files database.
  435. * Assumes the format is that appropriate for the BBS type
  436. * for the current BBS.
  437. *********************************************************************
  438. #endcomment
  439.  
  440. proc import
  441. strparm NewFiles
  442. intparm NumFiles
  443. string UpdateMsg
  444. string NewFileString, NewFileName
  445. string FileDate, FileSize, NewFileDate, NewFileSize
  446. string idxFile, idxString
  447. string Month, Day, Year, ThisYear
  448. string dbfString
  449. integer MM, DD, YY, TY
  450. integer inidx
  451. integer NewFileLength
  452. long dbfIndex, dbfLength
  453.     ;make sure the file exists before opening it
  454.     if isfile NewFiles
  455.         openfile(NewFilesFile, NewFiles, _READWRITE, _TEXT)
  456.         if checkfile(BBSidx) && checkfile(BBSdbf)
  457.             ;If both the index and database files exist, open them
  458.             openfile(BBSidxFile, BBSidx, _READWRITE, _NORMAL)
  459.             openfile(BBSdbfFile, BBSdbf, _READWRITE, _NORMAL)
  460.         else
  461.             ;If either the index or database file is missing, start from scratch
  462.             openfile(BBSidxFile, BBSidx, _CREATE, _NORMAL)
  463.             openfile(BBSdbfFile, BBSdbf, _CREATE, _NORMAL)
  464.         endif
  465.         ;Go to the end of the description database
  466.         fseek BBSdbfFile 0 2
  467.  
  468.         ;Loop through each line of the file list checking for a valid date
  469.         ;in the position appropriate for the current BBS type.  If one is
  470.         ;found, it can be assumed this is the first line of a file
  471.         ;description.  Files older than 1980 and post-dated files are
  472.         ;ignored.
  473.  
  474.         fgets NewFilesFile NewFileString
  475.         while not feof NewFilesFile
  476.             ;loop through the file
  477.             profilerd MailRun BBS "BBSType" BBSType
  478.             if findstring(BBSType, "PCBoard") || findstring(BBSType, "RBBS")
  479.                 substr Month NewFileString 23 2
  480.                 substr Day NewFileString 26 2
  481.                 substr Year NewFileString 29 2
  482.             elseif findstring(BBSType, "WildCat")
  483.                 substr Month NewFileString 24 2
  484.                 substr Day NewFileString 27 2
  485.                 substr Year NewFileString 30 2
  486.             elseif findstring(BBSType "Auntie")
  487.                 substr Month NewFileString 21 2
  488.                 substr Day NewFileString 24 2
  489.                 substr Year NewFileString 27 2
  490.             endif
  491.             atoi Month MM
  492.             atoi Day DD
  493.             atoi Year YY
  494.             ThisYear = $DATE
  495.             strdelete ThisYear 0 6
  496.             atoi ThisYear TY
  497.             if (MM >= 1 && MM <= 12) && (DD >= 1 && DD <= 31) && \
  498.                 (YY >= 80 && YY <= TY)
  499.                 ;If there is a valid date in the correct position...
  500.                 ;Put in tab separators
  501.                 strupdt NewFileString "`t" 12 1
  502.                 if findstring(BBSType, "PCBoard") || findstring(BBSType, "RBBS")
  503.                     strupdt NewFileString "`t" 21 1
  504.                     strupdt NewFileString "`t" 31 1
  505.                 elseif findstring(BBSType, "WildCat")
  506.                     strupdt NewFileString "`t" 21 1
  507.                     strupdt NewFileString "`t" 32 1
  508.                     strdelete NewFileString  33 1
  509.                 elseif findstring(BBSType, "Auntie")
  510.                     strupdt NewFileString "`t" 20 1
  511.                     strupdt NewFileString "`t" 29 1
  512.                 endif
  513.                 
  514.                 ;Strip extra spaces
  515.                 strfind NewFileString "`t "
  516.                 while FOUND
  517.                     strreplace NewFileString "`t " "`t"
  518.                     strfind NewFileString "`t "
  519.                 endwhile
  520.                 strfind NewFileString " `t"
  521.                 while FOUND
  522.                     strreplace NewFileString " `t" "`t"
  523.                     strfind NewFileString " `t"
  524.                 endwhile
  525.                 
  526.                 if findstring(BBSType, "WildCat")
  527.                     ;remove commas from file size
  528.                     strextract FileSize NewFileString "`t" 1
  529.                     NewFileSize = FileSize
  530.                     strreplace NewFileSize "," ""
  531.                     strreplace NewFileString FileSize NewFileSize 1
  532.                 else            
  533.                     ;change date format from MM-DD-YY to MM/DD/YY
  534.                     strextract FileDate NewFileSTring "`t" 2
  535.                     NewFileDate = FileDate
  536.                     strreplace NewFileDate "-" "/"
  537.                     strreplace NewFileString FileDate NewFileDate 1
  538.                     if strfind BBSType, "Auntie"
  539.                         strextract FileDate NewFileString "`t" 0
  540.                         NewFileDate = FileDate
  541.                         strreplace NewFileDate " " "." 1
  542.                         strfind NewFileDate ". "
  543.                         while FOUND
  544.                             strreplace NewFileDate ". " "."
  545.                             strfind NewFileDate ". "
  546.                         endwhile
  547.                         strreplace NewFileString FileDate NewFileDate 1
  548.                     endif
  549.                 endif
  550.                 strextract NewFileName NewFileString "`t" 0
  551.                 if NewfileFilter
  552.                     ;If the newfile filter is turned on...
  553.                     inidx = 0
  554.                     rewind BBSidxFile
  555.                     fgets BBSidxFile idxString
  556.                     while not feof BBSidxFile
  557.                         ;Check the filename against each file in the index
  558.                         strextract idxFile idxString "`t" 0
  559.                         if strcmpi idxFile NewFileName
  560.                             inidx = 1
  561.                             exitwhile
  562.                         endif
  563.                         fgets BBSidxFile idxString
  564.                     endwhile
  565.                     if inidx
  566.                         ;If the file is in the index, drop it
  567.                         fgets NewFilesFile NewFileString
  568.                         loopwhile
  569.                     endif
  570.                 endif
  571.                 fseek BBSidxFile 0 2
  572.                 NumFiles++
  573.                 strfmt UpdateMsg \
  574.                     "Updating database...      %d files added...      %s" \
  575.                     NumFiles NewFileName
  576.                 statmsg UpdateMsg
  577.                 strlwr NewFileName
  578.                 strlen NewFileName NewFileLength
  579.                 strupdt NewFileString NewFileName 0 NewFileLength
  580.                 ;Append the index
  581.                 ftell BBSdbfFile dbfIndex
  582.                 strfmt NewFileString "%s`t%ld" NewFileString dbfIndex
  583.                 fputs BBSidxFile NewFileString
  584.                 ;Get the first line of the description and put it in
  585.                 ;the database
  586.                 strextract dbfString NewFileString "`t" 3
  587.                 fputs BBSdbfFile dbfString
  588.                 ;Auntie lists have a blank line before the description
  589.                 if strfind BBSType "Auntie"
  590.                     fgets NewFilesFile NewFileString
  591.                 endif
  592.                 fgets NewFilesFile NewFileString
  593.                 ;Get remaining lines of description
  594.                 while checknfstring(&NewFileString)
  595.                     fstrfmt BBSdbfFile " %s" NewFileString
  596.                     fgets NewFilesFile NewFileString
  597.                 endwhile
  598.                     
  599.                 ;Find the length of the description and append to the index file
  600.  
  601.                 ftell BBSdbfFile dbfLength
  602.                 dbfLength -= dbfIndex
  603.                 fstrfmt BBSidxFile "`t%ld" dbfLength
  604.                 fputs BBSidxFile "`r`n"
  605.             else
  606.                 ;If this isn't a file description, get the next line
  607.                 fgets NewFilesFile NewFileString
  608.             endif
  609.         endwhile
  610.         fclose NewFilesFile
  611.         fclose BBSidxFile
  612.         fclose BBSdbfFile
  613.     endif
  614. endproc
  615.  
  616.  
  617. #comment
  618. *********************************************************************
  619. * CHECKNFSTRING()
  620. * Called by import()
  621. * Checks a string for the format appropriate for a
  622. * description line.  If it is a proper description line
  623. * the line is formatted and a value of 1 is returned.
  624. * If it is not proper, a value of 0 is returned.
  625. *********************************************************************
  626. #endcomment
  627.  
  628. func checknfstring : integer
  629. strparm NewFileString
  630. string Blanks
  631. integer i
  632.     if strfind BBSType "PCBoard"
  633.         strset blanks ' ' 33
  634.         if rstrcmp blanks NewFileString 33
  635.             strdelete NewFileString 0 33
  636.             return 1
  637.         endif
  638.     elseif strfind BBSType "WildCat"
  639.         strpeek NewFileString 33 i
  640.         if i == '|'
  641.             strdelete NewFileString 0 35
  642.             return 1
  643.         endif
  644.     elseif strfind BBSType "Auntie"
  645.         strset blanks ' ' 9
  646.         if rstrcmp blanks NewFileString 9
  647.             strdelete NewFileString 0 9
  648.             return 1
  649.         endif
  650.     endif
  651.     return 0
  652. endfunc
  653.  
  654.  
  655. #comment
  656. *********************************************************************
  657. * DELDLFILE()
  658. * Called by main()
  659. * Calls openfile(), interfaceon(), interfaceoff(),
  660. * makefullname(), makedesc(), clearfiledesc()
  661. * Deletes a file from the BBS's download index and selects
  662. * the next file in the list.
  663. *********************************************************************
  664. #endcomment
  665.  
  666. proc deldlfile
  667. string OldBBSidx, idxFile, idxString, temp
  668.     interfaceoff()
  669.     OldBBSidx = makefullname(TempDir, "OLIDX.TMP")
  670.     copyfile BBSidx OldBBSidx
  671.     openfile(OldidxFile, OldBBSidx, _READWRITE, _TEXT)
  672.     openfile(BBSidxFile, BBSidx, _CREATE, _TEXT)
  673.     fgets OldidxFile idxString
  674.     while not feof OldidxFile
  675.         strextract idxFile idxString "`t" 0
  676.         if strcmpi idxFile FileName
  677.             exitwhile
  678.         endif
  679.         fputs BBSidxFile idxString
  680.         fgets OldidxFile idxString
  681.     endwhile
  682.     fgets OldidxFile idxString
  683.     FileChoice = idxString
  684.     while not feof OldidxFile
  685.         fputs BBSidxFile idxString
  686.         fgets OldidxFile idxString
  687.     endwhile
  688.     if NULLSTR FileChoice
  689.         fseek BBSidxFile -100 2
  690.         fgets BBSidxFile temp
  691.         while not NULLSTR temp
  692.             FileChoice = temp
  693.             fgets BBSidxFile temp
  694.         endwhile
  695.     endif
  696.     fclose BBSidxFile
  697.     fclose OldidxFile
  698.     if not NULLSTR FileChoice
  699.         strextract FileName FileChoice "`t" 0
  700.         makedesc(BBSdbf)
  701.     else
  702.         clearfiledesc()
  703.         FileName = ""
  704.     endif
  705.     interfaceon()
  706. endproc
  707.  
  708.  
  709. #comment
  710. *********************************************************************
  711. * DLFILEBOX()
  712. * Called by main()
  713. * Displays the Download Files dialog box.
  714. *********************************************************************
  715. #endcomment
  716.  
  717. proc dlfilebox
  718. PermRadio = 2
  719. Conf = "0"
  720. destroydlg
  721. HelpPage = 9
  722. dialogbox 19 38 324 201 15 "Download Files" helpid HelpPage
  723.    text  12 27 56 8 left "Filename"
  724.    text  70 27 40 8 left "Size"
  725.    text  104 27 34 8 left "Date"
  726.    text  142 27 117 8 left "Description"
  727.    flistbox 12 38 300 50 BBSidx DXFileTabs single FileChoice
  728.    groupbox 12 89 300 17
  729.    radiobutton 26 94 60 11 "Unsorted" DLSortField
  730.    radiobutton 91 94 67 11 "Sort by Name" 
  731.    radiobutton 172 94 61 11 "Sort by Size" 
  732.    radiobutton 241 94 62 11 "Sort by Date" endgroup
  733.    text  13 112 49 8 left "Filename:"
  734.    editbox 12 122 101 12 FileName
  735.    text  129 112 67 8 left "Description:"
  736.    ftext 129 122 182 50 FileDesc
  737.    text  13 141 56 8 right "Purge files after"
  738.    text  96 141 16 8 left "days"
  739.    editbox 74 139 16 12 DLPurgeLimit
  740.    text  14 158 78 8 right "D/L from Conference:"
  741.    editbox 96 156 16 12 Conf
  742.    radiobutton 12 178 53 13 "Permanent" PermRadio
  743.    radiobutton 70 178 54 13 "Temporary" endgroup
  744.    pushbutton 130 179 30 14 "&Add" normal default
  745.    pushbutton 168 179 30 14 "De&lete" normal
  746.    pushbutton 206 179 30 14 "&Import" normal
  747.    pushbutton 244 179 30 14 "&Purge" normal
  748.    pushbutton 282 179 30 14 "&Done" cancel
  749.    text  76 9 80 8 right "Download File from:"
  750.    combobox 160 7 70 42 BBSList BBS sort
  751. enddialog
  752. endproc
  753.  
  754.  
  755.  
  756.